/*
 * max7219.c
 *
 * Created: 14.01.2013 15:13:02
 *  Author: saenko
 */ 
#include <avr/io.h>
#include "spi.h"

#define SS 2

void max7219_cmd(unsigned char addr, unsigned char data)
{
	PORTB &= ~(1<<SS);
	spi_tx(addr);
	spi_tx(data);
	
	PORTB |= (1<<SS);
}

void max7219_test(void)
{
	max7219_cmd(0x0F,0x00);
}

void max7219_out_time(unsigned char hh,unsigned char mm)
{
	max7219_cmd(0x04,mm&0b00001111);
	max7219_cmd(0x03,mm>>4);
	max7219_cmd(0x02,hh&0b00001111);
	max7219_cmd(0x01,hh>>4);
}
